# -*- coding: utf-8 -*-

from os import listdir
import numpy as np
import cv2

fourcc = cv2.VideoWriter_fourcc(*'XVID') #opencv3
#fourcc = cv2.cv.FOURCC('X','V','I','D') #opencv2
out = cv2.VideoWriter('output.avi',fourcc, 10.0, (568,320))

filepath = "D:\\test"
fileList=listdir(filepath)

print(fileList)

#import glob
#for filename in glob.glob(r"E:\\Materials\*jpg"):
    #print filename
i = 0
winName = ""
for filename in fileList:
  print(filename)
  if filename[-3:]=='jpg' or filename[-3:]=='png' or filename[-3:]=='bmp':
    i=i+1
    filename = "D:\\test\\" + filename
    img = cv2.imread(filename)
    if(img is not None):
      winName = "Num"+str(i)
      img=cv2.resize(img,(568,320), interpolation=cv2.INTER_CUBIC)
      cv2.imshow(winName, img)
      out.write(img)
      cv2.waitKey(10)

cv2.waitKey(0)
out.release()
cv2.destroyAllWindows()
      

 

      
